package Lambda;

public class LambdaDemo1 {
    public static void main(String[] args) {
        Animal a = new Animal() {
            @Override
            public void cry() {
                System.out.println("汪汪汪");
            }
        };
        a.cry();
//        lambda并不是可以简化全部的匿名内部类，只能简化函数式接口的匿名内部类
//        Animal a1 = ()->
//        {
//            System.out.println("汪汪汪");
//        }
//    };
//        a1.cry();
        Swim s1 = new Swim() {
            @Override
            public void swimming() {
                System.out.println("学生游泳贼好");
            }
        };
        s1.swimming();

        Swim s2 = ()->
        {
            System.out.println("老师游泳贼好");
        };
        s2.swimming();


    }

}
//函数是接口：只有一个抽象方法的接口。
@FunctionalInterface
interface Swim
{
    void swimming();
}